<template>
  <div class="home">
    评分：<input
      type="number"
      name=""
      v-model.number="rateValue"
      @input="inp"
    />
    <my-rate :rateValue="rateValue" @callFather="methodFather"></my-rate>
  </div>
</template>

<script>
// @ is an alias to /src
import MyRate from "../components/myRate.vue";

export default {
  data() {
    return {
      rateValue: 3,
    };
  },
  components: {
    MyRate,
  },
  methods: {
    methodFather(val) {
      this.rateValue = val;
    },
    inp() {
      if (this.rateValue < 0) {
        this.rateValue = 0;
      }
      if (this.rateValue > 5) {
        this.rateValue = 5;
      }
      if (this.rateValue == "") {
        this.rateValue = 0;
      }
    },
  },
};
</script>
